
package com.jf.cloud.api.platform.feign;

import com.jf.cloud.api.platform.vo.SysConfigApiVO;
import com.jf.cloud.common.bean.Domain;
import com.jf.cloud.common.feign.FeignInsideAuthConfig;
import com.jf.cloud.common.response.ServerResponseEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author zz
 * @date 2020/11/23
 */
@FeignClient(value = "jfcloud-platform",contextId = "config")
public interface ConfigFeignClient {


    /**
     * 获取配置信息
     * @param key key
     * @return 配置信息json
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/config/getConfig")
    ServerResponseEntity<String> getConfig(@RequestParam("key") String key);


    /**
     * 保存or修改配置
     * @param sysConfigApiVO sysConfig
     * @return void
     */
    @PostMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/config/saveOrUpdateSysConfig")
    ServerResponseEntity<Void> saveOrUpdateSysConfig(@RequestBody SysConfigApiVO sysConfigApiVO);

    /**
     * 获取配置信息，并返回对应的类
     * @param key key
     * @param clazz 类
     * @return 泛型
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/config/getSysConfigObject")
    ServerResponseEntity<Domain> getSysConfigObject(@RequestParam("key") String key, Class<Domain> clazz);
}
